<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="css/reset.css" type="text/css" media="all">
<link rel="stylesheet" href="css/buiding.css" type="text/css" media="all">
<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
</head>
<body>
	<div id="warp">
    	<div id="header">
        </div>
        <!-- end header-->
        <div id="content">
        	<div id="leftMenu">
            	<ul class="navi">
                	<li><a>Trang chủ</a></li>
                    <li><a>Giới thiệu</a></li>
                    <li><a>Hướng dẫn</a></li>
                    <li><a>Chat</a></li>
                    <li class="marbottom20"><a>Đăng nhập</a></li>
                    
                	<li><a>Forum</a></li>
                    <li><a>Cốt truyện</a></li>
                    <li><a>Trợ giúp</a></li>
                    <li><a>Liên hệ</a></li>
                    <li><a>Tìm hiểu</a></li>
                </ul>
            </div>
            <!-- end left menu-->
            <div id="viewInfo">
            	<div class="resource martop5 marleft20">
                	<table>
                    	<tr>
                        	<td width="80" title="Thịt">
								<span class="resFood"><?php echo $res['food'];?></span>/<?php echo $res['maxstore'];?>
                            </td>
                            
                            <td width="80" title="Gỗ">
								<span class="resWood"><?php echo $res['wood'];?></span>/<?php echo $res['maxstore'];?>
                            </td>
                            
                            <td width="80" title="Kim loại">
								<span class="resMetal"><?php echo $res['metal'];?></span>/<?php echo $res['maxstore'];?>
                            </td>
                            
                            <td width="80" title="Dầu mỏ">
								<span class="resPetro"><?php echo $res['petroleum'];?></span>/<?php echo $res['maxstore'];?>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="infoBuild martop10 marleft20 float-left">
					
                </div>
            </div>
            <!-- end view info-->
        </div>
        <script>
			function goTraining(obj){
				var val = $('#' + obj).val();
				var data = "obj="+ obj+"&val="+ val; 
				$.ajax({
					 type: "POST",
					 url: '<?php echo STATIC_DOMAIN;?>home/add_military',
					 data: data,
					 success: function(html){
						window.location.reload();
					 }
				 });	
			}
			numberUp('.resFood', <?php echo $res['food'];?>, 1, <?php echo $res['maxstore'];?>, <?php echo $rfood;?>);
			numberUp('.resWood', <?php echo $res['wood'];?>, 1, <?php echo $res['maxstore'];?>, <?php echo $rwood;?>);
			numberUp('.resMetal', <?php echo $res['metal'];?>, 1, <?php echo $res['maxstore'];?>, <?php echo $rmetal;?>);
			numberUp('.resPetro', <?php echo $res['petroleum'];?>, 1, <?php echo $res['maxstore'];?>, <?php echo $rpetroleum;?>);
			function numberUp(obj, number, val, limit, timer)
			{
				if(number >= limit)
				{
					return;
				}
				setTimeout(function(){nUp(obj, number, val, limit, timer)}, timer);
			}
			
			function nUp(obj, number, val, limit, timer)
			{
				if(number < limit)
				{
					number = number+val;
					$(obj).html(number);
				}
				else
				{
					return;
				}
				setTimeout(function(){numberUp(obj, number, val, limit, timer)}, timer);
			}
			
			
			function ww_timer(timer, obj)
			{
				if(timer != '00:00:00')
				{
					ww_count_down(timer, obj);
				}
				else
				{
					//reload page
					window.location.reload();
				}
				return;
			}
			function ww_count_down(timer, obj)
			{
				var arr_timer = timer.split(":");
				var second = arr_timer[2];
				var minuter = arr_timer[1];
				var hour = arr_timer[0];
				if(second > 0)
				{
					second = second - 1;
					if(second< 10)
					{
						second = '0' + second;
					}
				}
				else if(second == 0 && minuter > 0)
				{
					minuter = minuter - 1;
					second = 59;
					if(minuter < 10)
					{
						minuter = '0' + minuter;
					}
				}
				else if(second == 0 && minuter == 0)
				{
					hour = hour - 1;
					minuter = 59;
					second = 59;
					if(hour < 10)
					{
						hour = '0' + hour;
					}
				}
				timer = hour+':'+minuter+':'+second;
				$('.' + obj).html(timer);
				//document.getElementById(obj).innerHTML = timer;
				setTimeout(function(){ww_timer(timer, obj)},1000);
				return;
			}
		</script>
        <!-- end content-->
        <div id="footer">
        </div>
        <!-- end footer-->
    </div>
</body>
</html>